#include "MoveStep.h"

MoveStep::MoveStep(): gameBoard(0), movableInterface(0), movableObject(0)
{
}

MoveStep::MoveStep(const MoveStep& rhs): gameBoard(rhs.gameBoard), movableInterface(rhs.movableInterface), movableObject(rhs.movableObject), moveDirection(rhs.moveDirection)
{
}

MoveStep::~MoveStep()
{
}

void MoveStep::Execute()
{
	if (gameBoard && movableInterface && movableObject)
	{
		switch (moveDirection.Type())
		{
			case Direction::WEST:
				movableInterface->MoveLeft();
			break;
			case Direction::EAST:
				movableInterface->MoveRight();
			break;
			case Direction::NORTH:
				movableInterface->MoveUp();
			break;
			case Direction::SOUTH:
				movableInterface->MoveDown();
			break;
		}

		gameBoard->Update(movableObject);
	}
}

void MoveStep::SetObject(GameObject* object, Movable* movable)
{
	movableInterface = movable;
	movableObject = object;
}

void MoveStep::SetDirection(const Direction& direction)
{
	moveDirection = direction;
}

void MoveStep::SetBoard(Board* board)
{
	gameBoard = board;
}

MoveStep* MoveStep::Clone() const
{
	return new MoveStep(*this);
}
